package com.unisal.java;

public class ControleRemoto {

	Comando[] onCommands;
	Comando[] offCommands;

	public ControleRemoto() {
		onCommands = new Comando[7];
		offCommands = new Comando[7];

		Comando noCommand = new SemComando();
		for (int i = 0; i < 7; i++) {
			onCommands[i] = noCommand;
			offCommands[i] = noCommand;
		}
	}

	public void setCommand(int slot, Comando onCommand, Comando offCommand) {
		onCommands[slot] = onCommand;
		offCommands[slot] = offCommand;
	}

	public void onButtonsPressed(int slot){
		onCommands[slot].execute();
	}
	
	public void offButtonsPressed(int slot){
		offCommands[slot].execute();
	}
	
	@Override
	public String toString() {
		StringBuffer stringBuff = new StringBuffer();
		stringBuff.append("\n---- Controle Remoto ----\n");
		for ( Integer indice = 0; indice < onCommands.length; indice++){
			stringBuff.append("[slot " + indice + "]" + onCommands[indice].getClass().getName() +
					"\t  " + offCommands[indice].getClass().getName() + "\n");
		}
		return stringBuff.toString();
	}
}
